package cn.lanqiao.springbootproject.mapper;

import cn.lanqiao.springbootproject.entity.User;
import cn.lanqiao.springbootproject.vo.QueryUserVO;
import cn.lanqiao.springbootproject.vo.UserRoleVO;
import cn.lanqiao.springbootproject.vo.UserVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {

    @Select("select u.*,r.role_name from user u, role r, user_role ur where u.user_id = ur.user_id and r.role_id = ur.role_id")
    List<UserVO> queryUserList();

    List<User> queryByUserName(User user);

    @Insert("insert into sys_user (user_name,password,birthday) values (#{userName},#{password},#{birthday})")
    @Options(useGeneratedKeys = true,keyProperty = "userId")
    void insert(User user);


    UserRoleVO userLogin(QueryUserVO queryUserVO);
}
